from c1_2_p2_frequent_words import frequency_table


def find_clumps(text, k, l, t):
    patterns = []
    for i in range(len(text)-l):
        window = text[i: i+l]
        freq_map = frequency_table(window, int(k))
        for pattern, count in freq_map.items():
            if count >= t:
                patterns.append(pattern)

    return len(set(patterns))


if __name__ == "__main__":
    lines = open("E_coli.txt").readlines()
    genome = lines[0].replace("\n", "")

    k = 9
    l = 500
    t = 3

    print(find_clumps(genome, k, l, t))